package com.teamone.etl.accountant.service.impl;

import com.teamone.etl.accountant.entity.TicketAddress;
import com.teamone.etl.accountant.dao.TicketAddressDao;
import com.teamone.etl.accountant.service.TicketAddressService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 发票地址(TicketAddress)表服务实现类
 *
 * @author makejava
 * @since 2021-01-22 15:14:36
 */
@Service("ticketAddressService")
@Transactional(rollbackFor = Exception.class)
public class TicketAddressServiceImpl implements TicketAddressService {
    @Resource
    private TicketAddressDao ticketAddressDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TicketAddress queryById(Integer id) {
        return this.ticketAddressDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketAddress> queryAllByLimit(int offset, int limit) {
        return this.ticketAddressDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketAddress 实例对象
     * @return 实例对象
     */
    @Override
    public TicketAddress insert(TicketAddress ticketAddress) {
        this.ticketAddressDao.insert(ticketAddress);
        return ticketAddress;
    }

    /**
     * 修改数据
     *
     * @param ticketAddress 实例对象
     * @return 实例对象
     */
    @Override
    public TicketAddress update(TicketAddress ticketAddress) {
        this.ticketAddressDao.update(ticketAddress);
        return this.queryById(ticketAddress.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.ticketAddressDao.deleteById(id) > 0;
    }
}